import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class PerformMainPage extends StatefulWidget {
  PerformMainPage({Key? key}) : super(key: key);

  @override
  _PerformMainPageState createState() => _PerformMainPageState();
}

class _PerformMainPageState extends State<PerformMainPage> {
  Color _tabTextColor = Colors.black;
  String citySelect = '南京';
  int _today = 0;

  @override
  void initState() {
    super.initState();
    DateTime dateTime = DateTime.now();
    _today = dateTime.day;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // centerTitle: true,
        title: Text(
          '演出',
          style: TextStyle(color: Colors.black),
        ),
        backgroundColor: Colors.white,
        elevation: 1,
        // bottom: PreferredSize(
        //   preferredSize: Size.fromHeight(50.h),
        //   child: Container(),
        // ),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            _row(),
          ],
        ),
      ),
    );
  }

  Widget _row() {
    return Padding(
      padding: EdgeInsets.only(top: 10.h),
      child: Row(
        children: [
          SizedBox(width: 4.w),
          GestureDetector(
            //TODO: 城市选择器
            // onTap: _getCity,
            onDoubleTap: () {
              citySelect = '南京';
              setState(() {});
            },
            child: Row(
              children: [
                Text(
                  citySelect,
                  style: TextStyle(
                      color: _tabTextColor,
                      fontSize: 13.sp,
                      fontWeight: FontWeight.bold),
                ),
                Icon(
                  Icons.arrow_drop_down,
                  color: _tabTextColor,
                  size: 20.r,
                )
              ],
            ),
          ),
          Expanded(
            child: Container(
              margin: EdgeInsets.symmetric(horizontal: 10.w),
              padding: EdgeInsets.symmetric(horizontal: 5.w, vertical: 5.h),
              // height: 30.h,
              decoration: BoxDecoration(
                color: Colors.grey[200],
                borderRadius: BorderRadius.all(
                  Radius.circular(20.r),
                ),
              ),
              child: Row(
                children: [
                  Icon(
                    Icons.search,
                    size: 16.r,
                    color: Color(0xFFa0a2c9),
                  ),
                  Expanded(
                      child: Text(
                    '搜影片、影院',
                    overflow: TextOverflow.ellipsis,
                    maxLines: 1,
                    style: TextStyle(
                        color: Color(0xFFa0a2c9),
                        fontSize: 12.sp,
                        fontWeight: FontWeight.bold),
                  ))
                ],
              ),
            ),
          ),
          SizedBox(width: 15),
          Stack(
            children: [
              Image.asset(
                'assets/images/calendar_bg.png',
                width: 25.w,
                height: 25.w,
                fit: BoxFit.fill,
                color: _tabTextColor,
              ),
              Container(
                //当数字小于10的时候 left为12,大于10为8
                padding:
                    EdgeInsets.only(top: 8.h, left: _today < 10 ? 9.w : 6.w),
                child: Center(
                  child: Text(
                    _today.toString(),
                    style: TextStyle(color: _tabTextColor, fontSize: 12.sp),
                  ),
                ),
              )
            ],
          ),
          SizedBox(width: 10.w),
        ],
      ),
    );
  }
}
